import {HTTP_REQUEST_URL} from '@/config/app';
import {mapState} from "vuex"
export default {
	data(){
		return {
			copyContent:'',
			copyTitle:'',
			modalName:'',
			copyImg:'',
			banners:[],
		}
	},
	computed: {
		...mapState({
			themeColor: state => state.app.themeColor,
			appletName: state => state.app.appletName,
			appletSolgn: state => state.app.appletSolgn,
			appletLogo: state => state.app.appletLogo,
			shareImage: state => state.app.shareImage,
			shareTitle: state => state.app.shareTitle,
		})
	},
	methods:{
		navTo(item){
			console.log(item);
			switch(item.jump_way){
				case "list"://列表页面
					if(item.list_info.list_detail == undefined || item.list_info.list_detail.lenght <= 0){
						return;
					}
					
					this.toPage('/pages/common/common_list?p_table_name=life_module_item&pid='+item.id+'&icon='+item.logo);
				break;
				
				case 'mini_outer'://外部小程序
					if(!item.appid || !item.mini_path) return;
				
					uni.navigateToMiniProgram({
						appId:item.appid,
						path:item.mini_path
					})
				break;
				
				case 'mini_self'://自身页面
					if(!item.mini_path) return;
					
					uni.navigateTo({
						url: item.mini_path,
						animationType: 'pop-in',
						animationDuration: 200
					});
				break;
				
				case 'modal_img'://弹窗图片
					if(!item.img_path){
						return;
					}
					// this.copyContent = item.copy;
					this.copyImg = item.img_path;
					this.modalName = 'Image';
				break;
				
				case 'full_img'://全屏页面
					if(!item.img_path){
						return;
					}
					
					this.toPage('/pages/common/img?img='+item.img_path);
				break;
				
				case 'full_tw'://图文
					this.toPage('/pages/common/tw?pid='+item.id+'&p_table_name='+item.table_name);
				break;
				
				case 'tenxun_video'://微信视频号
					if(!item.finder_name || !item.feed_id){
						return;
					}
					wx.openChannelsActivity({
						finderUserName:item.finder_name,
						feedId:item.feed_id,
						fail:function(error){
							console.log(error);
						}
					})
				break;
			}
		},
		hideModal(){
			this.modalName = '';
		},
		doCopy(){
			var _this = this;
			uni.setClipboardData({
				data: this.copyContent,
				success: function () {
					//_this.modalName = '';
				}
			});
		},
		toPage(path){
			uni.navigateTo({url: path});
		},
		BackPage() {
			uni.navigateBack({ delta: 1 });
		},
		showImg(hash){
			return HTTP_REQUEST_URL+'/api/mini/upload/showFile/'+hash;
		}
	}
}
